{% extends "base.html" %}
{% load profile_extras %}
{% block head %}
<link href="/medias/css/group.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
$(function(){
	$(".bevel_top").corner("bevel top");
	$(".bevel_button").corner("bottom");

});	
	
function postnote(){
	var n = $("#note").val();
	if(n == null|| n==""){
		$("#nerorr").html("先要有字");
		return false;
	}
	return true;
} 
function delete_note(id)
{
	if(confirm("你确定要删除吗?")){
		$.ajax({
		   type: "POST",
		   url: "/note/delete/"+id+"/",
		   success: function(result){
		     if(result=="ok")
			 {
			 	$("#note"+id).fadeOut(900);
			 }
			 else{
			 	
			 }
		   }
		}); 
	}
}
function reply_note(user,id){
	$("#note").val("@"+user+" "+$("#note").val());
	$("#note").focus();
}
</script>
{% endblock %}

{% block title %}mobeir社区{% endblock %}

{% block left_content %}

<div id="group_header" class="bevel_top">
	<ul >
		<li class="active corner"><a href="/group/">动态</a></li>
		<li><a href="/group/my/">我的圈子</a></li>
		<li><a href="/group/topic/my/">我发起的圈子主题</a></li>
		<li><a href="/group/replies/my/">我回复的圈子主题</a></li>
		<li><a href="/group/all/">所有圈子</a></li>
	</ul>
</div>
<div id="note_text_box" class="bevel_button">
<form style="text-align:left;" action="/group/note/post/" method="post" onsubmit="return postnote();">{% csrf_token %}
    <textarea id="note" name="note" class="corner" ></textarea>
	<input class="button corner" type="submit" value="说吧"><span style="margin-left:10px;color:#0080ff;" id="nerorr"></span>
</form>
</div>
<div id="group_notes">
{% for note in cnotes.object_list  %}
<div id="note{{note.id}}">	
	<div id="group_sub_note">
		<img alt="{{note.user.username}}" src="/medias/{{note.user_image}}" />
		
		<div class="op_note">
			{% ifequal request.user.username note.user.username%}
		    <a href="javascript:void(0);" onclick="delete_note('{{note.id}}');"><img src="/medias/images/delete_note.gif"/></a>
			{% else %}
			<a href="#" onclick="reply_note('{{note.user.username}}','{{note.id}}')"><img src="/medias/images/reply_note.gif"/></a> 
			{% endifequal %}
		</div>
		<div class="note_text"><a href=" #">{{note.user.username}}</a>:&nbsp&nbsp;{{note.content|slice:":280"|escape}}......</div>
	</div>	
</div>
{% endfor %}

<div id="pagecut" class="pagination">
    <span class="step-links">
        {% if cnotes.has_previous %}
            <a href="?page={{ cnotes.previous_page_number }}"><< 较新的</a>
        {% endif %}

        <span class="current">
             {{ cnotes.number }} / {{ cnotes.paginator.num_pages }} 
        </span>

        {% if cnotes.has_next %}
            <a href="?page={{ cnotes.next_page_number }}">较早的 >></a>
        {% endif %}
    </span>
</div>

</div>

{% if request.user.is_anonymous %}
<div id="midLeft">
<h3><span class="sLeft">最受关注圈子</span><span class="sRight"></span></h3>
	
{% for group in groups %}
<div class="sub-item">
	<div class="pic">
		<a href="/group/{{group.id}}"><img  width=50 height=50 alt="{{group.name}}" src="/medias/{{group.image}}"></a>
	</div>
	<div class="info">
		<a href="/group/{{group.id}}">{{group.name}}</a> (30539)</br>{{group.summary|slice:":40"}}...
	</div>
</div>
{% endfor %}		
</div>
{% endif %}

{% endblock %}





{% block right_content %}

<h3><span class="sLeft">我关注的</span><span class="sRight"></span></h3>
{% for fuser in follows %}
<div id="sub-persion">
<ul>
	<li><a href="#"><img alt="{{fuser.user.username}}" src="/medias/{{fuser.image}}" width=46 height=46 /></a></li>
	<li><a href="#">{{fuser.user.username}}</a></li>
</ul>	
</div>
{% endfor %}
<h3><span class="sLeft">◇<a href="/group/add/">我要申请圈子</span></a></h3>
<div style="clear:both;"></div>
<h3><span class="sLeft">我加入的小组</span><span class="sRight"></span></h3>


<div id="sub-persion">
{% for group in mygroups %}
<ul>
	<li><a href="/group/{{group.id}}"><img alt="{{group.name}}" src="/medias/{{group.image}}" width=46 height=46 /></a></li>
	<li><a title="{{group.name}}" href="/group/{{group.id}}">{{group.name|slice:":9"|escape}}..</a></li>
</ul>	
{% endfor %}
</div>



{% endblock %}